<?php
include 'db.php';

if (isset($_GET['id'])) {
    $id = $_GET['id'];

    $stmt = $pdo->prepare("SELECT * FROM tools WHERE id = ?");
    $stmt->execute([$id]);
    $tool = $stmt->fetch(PDO::FETCH_ASSOC);

    if ($tool) {
        echo json_encode(['success' => true, 'tool' => $tool]);
    } else {
        echo json_encode(['success' => false, 'message' => '小工具未找到']);
    }
} else {
    echo json_encode(['success' => false, 'message' => 'Invalid request']);
}